package com.xbongbong.saas.script.tempenum;

import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.field.ItemPoJo;
import com.xbongbong.paas.field.LinkDetailPojo;
import com.xbongbong.pro.enums.SaasMarkEnum;
import com.xbongbong.saas.enums.ForbiddenSettingEnum;
import com.xbongbong.saas.enums.ShowTypeEnum;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import com.xbongbong.saas.enums.business.PromotionActivityManagementEnum;
import com.xbongbong.saas.enums.dictionary.MarketingStatusEnum;
import com.xbongbong.saas.script.help.InitExplainsHelper;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

/**
 *
 * @author jyh
 * @since v1.0
 * @version v1.0
 */
@Getter
public enum TempPromotionActivityManagementEnum {
    // 基本信息

    NAME(PromotionActivityManagementEnum.NAME),

    TYPE(PromotionActivityManagementEnum.TYPE),

    ACTIVITY_TIME(PromotionActivityManagementEnum.ACTIVITY_TIME),

    APPLICABLE_LOCATION(PromotionActivityManagementEnum.APPLICABLE_LOCATION),

    APPLICABLE_OBJECT_TYPE(PromotionActivityManagementEnum.APPLICABLE_OBJECT_TYPE),

    APPLICABLE_OBJECT(PromotionActivityManagementEnum.APPLICABLE_OBJECT),

    APPLICABLE_PRODUCT(PromotionActivityManagementEnum.APPLICABLE_PRODUCT),

    PRIORITY(PromotionActivityManagementEnum.PRIORITY),

    STATUS(PromotionActivityManagementEnum.STATUS),

    CREATOR_ID(PromotionActivityManagementEnum.CREATOR_ID),

    ADD_TIME(PromotionActivityManagementEnum.ADD_TIME),
    ;
    private PromotionActivityManagementEnum anEnum;

    TempPromotionActivityManagementEnum(PromotionActivityManagementEnum anEnum) {
        this.anEnum = anEnum;
    }

    public static List<TempPromotionActivityManagementEnum> getAllEnum() {
        List<TempPromotionActivityManagementEnum> list = new ArrayList<>();
        Collections.addAll(list, values());
        return list;
    }


    public static void initName(FieldAttrEntity fieldAttrEntity) {
        LinkDetailPojo linkDetailPojo = new LinkDetailPojo();
        linkDetailPojo.setBusinessType(XbbRefTypeEnum.PROMOTION_ACTIVITY_MANAGEMENT.getCode());
        linkDetailPojo.setSubBuisenssType(XbbRefTypeEnum.PROMOTION_ACTIVITY_MANAGEMENT.getCode());
        linkDetailPojo.setSaasMark(SaasMarkEnum.SAAS.getCode());
        linkDetailPojo.setAttr(NAME.getAnEnum().getAttr());
        fieldAttrEntity.setLinkDetail(linkDetailPojo);
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setDisableListSort(1);
    }

    public static void initType(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setDisableListSort(1);
    }

    public static void initActivityTime(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setDisableListSort(1);
    }

    public static void initApplicableLocation(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setDisableListSort(1);
    }

    public static void initApplicableObjectType(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setDisableListSort(1);
    }

    public static void initApplicableObject(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setDisableListSort(1);
    }


    public static void initApplicableProduct(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setDisableListSort(1);
    }

    public static void initPriority(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setDisableListSort(1);
    }

    public static void initCreatorId(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setDisableListSort(1);
    }

    public static void initAddTime(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setDisableListSort(1);
    }

    public static void initStatus(FieldAttrEntity fieldAttrEntity) {
        fieldAttrEntity.setIsDictionary(1);
        List<ItemPoJo> itemPoJos = InitExplainsHelper.setCombItemByEnum(MarketingStatusEnum.class, fieldAttrEntity.getFieldType());
        List<String> shipStatusCodeList = Arrays.asList(MarketingStatusEnum.ONLINE.getName(), MarketingStatusEnum.OFFLINE.getName(), MarketingStatusEnum.WAIT_ONLINE.getName());
        for (ItemPoJo itemPoJo: itemPoJos) {
            itemPoJo.setNoDel(1);
            itemPoJo.setNoEdit(1);
            if (!shipStatusCodeList.contains(itemPoJo.getText())) {
                itemPoJo.setShowType(ShowTypeEnum.NONE.getCode());
                itemPoJo.setEditHide(1);
            } else {
                if (Objects.equals(itemPoJo.getText(), MarketingStatusEnum.WAIT_ONLINE.getName())) {
                    itemPoJo.setChecked(true);
                }
            }
        }
        List<String> settingList = Arrays.asList(ForbiddenSettingEnum.DISABLE_OPTION_RELY.getAlias(), ForbiddenSettingEnum.DISABLE_SELF_DEFINE.getAlias());
        fieldAttrEntity.setForbiddenSettingList(settingList);
        fieldAttrEntity.setItemBanDefault(1);
        fieldAttrEntity.setItems(itemPoJos);
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setShowEditable(0);
        fieldAttrEntity.setEditable(0);
        fieldAttrEntity.setDisableListSort(1);
    }


}
